
package com.x52im.rbchat.logic.chat_group.impl;

import java.util.HashMap;

/**
 * 群聊时的发言太快检查和自动解禁检查器提供者(单例实现)。
 *
 * @author Jack Jiang
 * @since 4.3
 */
public class ProhibitSpeechCheckerProvider
{
    private static ProhibitSpeechCheckerProvider instance = null;

    /**
     * 发言过快检查器列表(key=gid、value=检查器实例).
     */
    private HashMap<String, ProhibitSpeechChecker>
            checkerList = new HashMap<String, ProhibitSpeechChecker>();


    public static ProhibitSpeechCheckerProvider getInstance()
    {
        if(instance== null)
            instance = new ProhibitSpeechCheckerProvider();
        return instance;
    }

    public ProhibitSpeechChecker getChecker(String gid)
    {
        ProhibitSpeechChecker c = checkerList.get(gid);
        if(c == null) {
            c = new ProhibitSpeechChecker("群"+gid);
            checkerList.put(gid, c);
        }

        return c;
    }

    public void clear()
    {
        this.checkerList.clear();
    }
}
